package com.csce.domain.entity.go_score;

import com.csce.domain.entity.go_score.dto.GoScoreExamDto;
import com.csce.domain.entity.go_score.dto.GoScoreExamPlaceDto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.doudou.core.container.ListUtil;
import com.doudou.core.date.DateUtil;
import com.osce.common.annotation.Excel;
import com.osce.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.util.Date;
import java.util.List;

/**
 * 妇产科考试对象 go_score_exam
 *
 * @author zzx
 * @since 2024-05-17
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
@EqualsAndHashCode(callSuper = true)
public class GoScoreExam extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @ApiModelProperty("${comment}")
    private Long id;

    /**
     * 名称
     */
    @Excel(name = "名称")
    @ApiModelProperty("名称")
    private String name;

    /**
     * 日期
     */
    @JsonFormat(pattern = DateUtil.yyyyMMdd)
    @Excel(name = "日期", width = 30, dateFormat = DateUtil.yyyyMMdd)
    @ApiModelProperty("日期")
    private Date date;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = DateUtil.HHmmss)
    @Excel(name = "开始时间", width = 30, dateFormat = DateUtil.HHmmss)
    @ApiModelProperty("开始时间")
    private Date startTime;

    /**
     * 结束时间
     */
    @JsonFormat(pattern = DateUtil.HHmmss)
    @Excel(name = "结束时间", width = 30, dateFormat = DateUtil.HHmmss)
    @ApiModelProperty("结束时间")
    private Date endTime;

    /**
     * 科室编号
     */
    @Excel(name = "科室编号")
    @ApiModelProperty("科室编号")
    private Long deptId;
    private String deptName;

    /**
     * 类型
     */
    @Excel(name = "类型")
    @ApiModelProperty("类型")
    private Integer type;

    /**
     * 状态
     */
    @Excel(name = "状态")
    @ApiModelProperty("状态")
    private Integer status;

    /**
     * 妇产科考试-考场信息
     */
    private List<GoScoreExamPlace> goScoreExamPlaceList;

    public GoScoreExamDto convertGoScoreExamDto(){
        GoScoreExamDto goScoreExamDto = new GoScoreExamDto();
        //基本属性
        goScoreExamDto.setId(this.id);
        goScoreExamDto.setName(this.name);
        goScoreExamDto.setDate(this.date);
        goScoreExamDto.setTimeRange(new Date[]{this.startTime,this.endTime});
        goScoreExamDto.setDeptId(this.deptId);
        goScoreExamDto.setDeptName(this.deptName);
        goScoreExamDto.setType(this.type);
        goScoreExamDto.setStatus(this.status);
        List<GoScoreExamPlaceDto> goScoreExamPlaceDtoList = ListUtil.linkedList();
        if (ListUtil.isNotEmpty(this.goScoreExamPlaceList)){
            for (GoScoreExamPlace placeDto : this.goScoreExamPlaceList) {
                GoScoreExamPlaceDto goScoreExamPlaceDto = placeDto.convertGoScoreExamPlaceDto();
                goScoreExamPlaceDtoList.add(goScoreExamPlaceDto);
            }
        }
        goScoreExamDto.setGoScoreExamPlaceList(goScoreExamPlaceDtoList);
        return goScoreExamDto;
    }
}
